package org.example.bucket;

import org.apache.flink.table.api.EnvironmentSettings;
import org.apache.flink.table.api.TableEnvironment;

public class FlinkRebucket {
    public static void main(String[] args) {
        final EnvironmentSettings settings = EnvironmentSettings.inBatchMode();
        final TableEnvironment tableEnv = TableEnvironment.create(settings);

        tableEnv.executeSql("CREATE CATALOG paimon WITH (\n" +
                "            'type' = 'paimon',\n" +
                "            'warehouse' = 'file:///tmp/paimon'\n" +
                "        );");

        tableEnv.executeSql("ALTER TABLE `paimon`.`default`.`user_behavior` SET ('bucket' = '20');");

        tableEnv.executeSql("INSERT OVERWRITE `paimon`.`default`.`user_behavior` /*+ OPTIONS('dynamic-partition-overwrite'='false') */\n" +
                "SELECT * FROM `paimon`.`default`.`user_behavior`;");
    }
}
